package com.pet.shop.dto;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PairDto<K, V> {

    private K k;
    private V v;

    public K getK() {
        return k;
    }

    public void setK(K k) {
        this.k = k;
    }

    public V getV() {
        return v;
    }

    public void setV(V v) {
        this.v = v;
    }

    public static <K, V> Map<K, V> toMap(List<PairDto<K, V>> pairs){
        Map<K, V> resultMap = new HashMap<>();
        if(pairs == null || pairs.isEmpty()) return resultMap;
        pairs.forEach(pair -> resultMap.put(pair.getK(), pair.getV()));
        return resultMap;
    }
}
